Do it in Dreamweaver: Form & CGI

Using Dreamweaver and the mailform CGI to create an e-mail form

Use Dreamweaver to create a form for your website. The file called mailform.cgi in the Techniques folder, when put in the proper place on a UNIX server, can process your form's data and send it to you in an e-mail.

To create a form:

1 Choose File > New to open a new Dreamweaver document.
2 Make sure that there is a check mark next to View > Invisible Elements.
3 Choose Insert > Form or click the form button in the Objects palette to insert a form boundary.
4 Click the <form> tag in the tag selector at the bottom of the Document window. In the Property inspector, set the value of the ACTION attribute to the name of the cgi script that will process the form ("mailform.cgi").
Your system administrator may require that all cgi scripts be stored in a specific directory. If this is the case, make sure that this is reflected in the path to mailform.cgi in the ACTION. For example, instead of ACTION="mailform.cgi", you may have ACTION="/cgi-bin/mailform.cgi".
5 In the Document window, click inside the form boundary and choose Insert > Form Element > Text Field, or click on the text field object in the Objects palette.
6 In the Property inspector, change the name of the field from TextField to mailto. In the Init Val box, type the e-mail address of the person who will receive the form submissions (put your own e-mail address here for the testing phase).
7 With the text field still selected, choose Window > HTML to open the HTML inspector. The code for the text field should be highlighted. Change the TYPE of the field from "text" to "hidden".
8 Repeat steps 5 and 6 to create a hidden field called "subject". In the Init Val box, type the text you want to appear on the Subject: line of the e-mail (for example, "Customer survey response").
9 Create the rest of your form as usual (see the Help topic "Creating a form" for more information).
Assign your fields simple names if you don't want the information to appear in the e-mail body. Otherwise, name them with a leading F, number, and underscore (for example, "F01_Name"). The numbers will dictate the order in which the fields appear in the e-mail. For multiple-word field names, use underscores in place of spaces (for example, "F01_Customer_name"). The script translates underscores to spaces automatically.

For example, say you've created five fields called F01_Customer_name, F02_Street_address, F03_City, F04_State, and F05_Zip. The person filling out the form types in Joe Normal, 433 Pine Street, Janeway, NB, 67554. The body of the e-mail would read:
	Customer name: Joe Normal
	Street address: 433 Pine Street
	City: Janeway
	State: NB
	Zip: 67554
If you want the user to choose one option from a list of many, use radio buttons or a list menu.

If you want the user to choose as many options as are applicable, use checkboxes. Give all boxes in the group the same name but different values. This way multiple values will be listed on one line:
	Favorite candies: jelly beans - gummy bears - peachy penguins
10 Save your form and upload it to a server (choose Window > Site to use Dreamweaver's Site FTP feature).

To use mailform.cgi to process your form:

1 Open mailform.cgi in a text editor (for example, BBEdit or HomeSite).
2 Read through the comments (marked with a # at the beginning of the line). If you are unsure whether any lines need to be changed to match your server setup, ask your system administrator.
3 When you have made any necessary changes, save the file and upload it to your server.
4 Change the permissions on mailform.cgi from read/write to read/write/execute.
Ask your system administrator for help if you do not know how to do this.
5 Start testing.
Open the form page in a browser, fill out the form and click Submit. Try this several times with different input to make sure everything works as expected. See the comments in the mailform.cgi file for help troubleshooting any processing problems. If you get the e-mail but the content isn't what you expected, review your HTML to see if perhaps you made any typos in field names or values.